package com.zxf.android.mobilesafe.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.zxf.android.mobilesafe.R;
import com.zxf.android.mobilesafe.bean.ContactInfo;

public class MyListAdapter extends BaseAdapter implements ListAdapter {
	private Context context ;
	private List<ContactInfo> contactInfoList ;
	

	public MyListAdapter(Context context,
			List<ContactInfo> contactInfoList) {
		this.context = context;
		this.contactInfoList = contactInfoList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return contactInfoList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return contactInfoList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null) {
			convertView = View.inflate(context, R.layout.contact_item, null);
		}
		
		TextView tv_userName = (TextView) convertView.findViewById(R.id.username);
		TextView tv_userNum = (TextView) convertView.findViewById(R.id.usernum);
		
		tv_userName.setText(contactInfoList.get(position).getUserName());
		tv_userNum.setText(contactInfoList.get(position).getUserNum());
		
		return convertView;
	}

}
